﻿<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
	{include file='export-head' /}
<title>订单列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 订单管理 <span class="c-gray en">&gt;</span> 订单列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<!--查询-->
	<div class="search text-c">
		<input type="text" name="batch_note" id="" placeholder=" 批次备注" style="width:250px" class="input-text">
		<button name="" id="" class="btn btn-success" onclick="searchFun(0)" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜备注</button>
	</div>
	<form hidden id="search-form" action="" method="post">
		<div class="panel mt-20">
			<div class="panel-heading">
				<span>查询条件</span>
				<a href="javascript:;" onclick="searchAdv()" class="directive-close"><i class="layui-icon">&#x1006;</i></a>
			</div>
			<div class="panel-body">
				<div class="search-adv">
					<ul class="search-ul">
						<li>
							<button class="btn btn-primary tab">订单编号：</button>
							<span class="select-ctrl">
							<select name="" class="select">
								<option value="0">等于</option>
								<option value="1">大于</option>
								<option value="2">小于</option>
								<option value="3">不等于</option>
							</select>
						</span>
							<input type="text" name="order_no" class="input-text main-input">
						</li>
						<li>
							<button class="btn btn-primary tab">日期范围：</button>
							{literal}
							<input type="text" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'logmax\')||\'%y-%M-%d\'}' })" id="logmin" class="input-text Wdate">
							-
							<input type="text" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'logmin\')}',maxDate:'%y-%M-%d' })" id="logmax" class="input-text Wdate">
							{/literal}
						</li>
						<li>
							<button class="btn btn-primary tab">企业报送类型：</button>
							<span class="select-ctrl">
							<select name="" class="select">
								<option value="0">等于</option>
								<option value="1">大于</option>
								<option value="2">小于</option>
								<option value="3">不等于</option>
							</select>
						</span>
							<span class="main-select">
							<select name="" class="select">
								<option value="1">新增</option>
								<option value="2">变更</option>
								<option value="3">删除</option>
							</select>
						</span>
						</li>
						<li>
							<button class="btn btn-primary tab">订单编号：</button>
							<span class="select-ctrl">
							<select name="" class="select">
								<option value="0">等于</option>
								<option value="1">大于</option>
								<option value="2">小于</option>
								<option value="2">不等于</option>
							</select>
						</span>
							<input type="text" name="order_no" class="input-text main-input">
						</li>
						<li>
							<button class="btn btn-primary tab">订单编号：</button>
							<span class="select-ctrl">
							<select name="" class="select">
								<option value="0">等于</option>
								<option value="1">大于</option>
								<option value="2">小于</option>
								<option value="2">不等于</option>
							</select>
						</span>
							<input type="text" name="order_no" class="input-text main-input">
						</li>
						<li>
							<button class="btn btn-primary tab">订单编号：</button>
							<span class="select-ctrl">
							<select name="" class="select">
								<option value="0">等于</option>
								<option value="1">大于</option>
								<option value="2">小于</option>
								<option value="2">不等于</option>
							</select>
						</span>
							<input type="text" name="order_no" class="input-text main-input">
						</li>
						<li>
							<button class="btn btn-primary tab">订单编号：</button>
							<span class="select-ctrl">
							<select name="" class="select">
								<option value="0">等于</option>
								<option value="1">大于</option>
								<option value="2">小于</option>
								<option value="2">不等于</option>
							</select>
						</span>
							<input type="text" name="order_no" class="input-text main-input">
						</li>
						<li>
							<button class="btn btn-primary tab">订单编号：</button>
							<span class="select-ctrl">
							<select name="" class="select">
								<option value="0">等于</option>
								<option value="1">大于</option>
								<option value="2">小于</option>
								<option value="2">不等于</option>
							</select>
						</span>
							<input type="text" name="order_no" class="input-text main-input">
						</li>
						<li>
							<button class="btn btn-primary tab">订单编号：</button>
							<span class="select-ctrl">
							<select name="" class="select">
								<option value="0">等于</option>
								<option value="1">大于</option>
								<option value="2">小于</option>
								<option value="2">不等于</option>
							</select>
						</span>
							<input type="text" name="order_no" class="input-text main-input">
						</li>
					</ul>
				</div>
			</div>
		</div>
		<div class="search-btns text-c mt-20">
			<input class="btn btn-primary radius" type="submit" value="查询" onclick="searchFun(1)" style="width: 80px;line-height: 1.5!important">
			<input class="btn btn-primary radius" type="reset" value="清空" style="width: 80px;line-height: 1.5!important;">
		</div>
	</form>
	<!--数据显示-->
	<div class="cl pd-5 bg-1 bk-gray mt-20">
		<span class="l">
			<a href="javascript:;" onclick="searchAdv()" class="btn btn-primary radius"><i class="layui-icon">&#xe615;</i> 高级查询</a>
			<a class="btn  btn-success radius" data-title="批量导出就手订单" onclick="exportTable(0)" href="javascript:;"><i class="Hui-iconfont">&#xe644;</i> 批量导出就手订单</a>
			<a class="btn  btn-success radius" data-title="批量导出清单" onclick="exportTable(1)" href="javascript:;"><i class="Hui-iconfont">&#xe644;</i> 批量导出清单</a>
			<a class="btn  btn-success radius" data-title="批量导出入库单" onclick="exportTable(2)" href="javascript:;"><i class="Hui-iconfont">&#xe644;</i> 批量导出入库单</a>
			<a class="btn  btn-success radius" data-title="批量导出运单" onclick="exportTable(3)" href="javascript:;"><i class="Hui-iconfont">&#xe644;</i> 批量导出运单</a>
			<a class="btn  btn-success radius" data-title="批量一次性导出" onclick="exportTable(4)" href="javascript:;"><i class="Hui-iconfont">&#xe641;</i> 批量一次性导出</a>
			<a id="upload_excel" class="btn  btn-danger radius" data-title="导入Excel文件" href="javascript:;"><i class="Hui-iconfont">&#xe642;</i> 导入Excel文件</a>
			<span id="filetips" hidden style="padding: 0 10px;color: #999;vertical-align: middle"></span>
			<a id="upcommit" class="btn  btn-secondary radius" onclick="uploading(this)" data-title="开始导入" href="javascript:;"><i class="Hui-iconfont">&#xe645;</i> 开始导入</a>
		</span>
		<span class="r total">共有数据：<strong></strong> 条</span>
	</div>
	<div class="mt-20 datas">
		<table id="orderLists" lay-filter="olist"></table>
	</div>
	<form hidden id="postData" action="{:url('admin/Order/exportData')}" method="post">
		<input type="text" name="ex_info">
	</form>
	<form id="batch_ex" hidden action="{:url('admin/Order/exportData')}" method="post">
	</form>
</div>
{include file='export-footer' /}

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__PUBLIC__/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/laypage/1.2/laypage.js"></script>
<script type="text/html" id="exportTools">
	<a class="layui-btn layui-btn-normal layui-btn-mini" lay-event="jiushou_ex">导出就手订单</a>
	<a class="layui-btn layui-btn-mini" lay-event="list_ex">导出清单</a>
	<a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="entry_ex">导出入库单</a>
	<a class="layui-btn layui-btn-warm layui-btn-mini" lay-event="transprot_ex">导出运单</a>
	<a class="layui-btn layui-btn-primary layui-btn-mini" lay-event="all_ex">一次性导出</a>
</script>
<script type="text/javascript">
layui.config({
	debug : true,
	version : true	 //清除缓存
});
//$.ajax({
//    url: "{:url(\'order/getDatas\')}",
//    success: function (res) {
//        //执行渲染
//
//    },
//    error: function () {
//        layer.open({
//            msg: "出错啦，快找管理猿！"
//        });
//    }
//});

//表格方法式渲染
layui.use(['table','layer','upload'],function () {
    var table = layui.table;
    var layer = layui.layer;
    var $ = layui.jquery;
    var upload = layui.upload;
    table.render({
        elem: '#orderLists' //指定原始表格元素选择器（推荐id选择器）
        ,id: 'main'
        ,height: 288 //容器高度
//        ,data: res.data
		,url: '{:url(\'order/getDatas\')}'
//        ,initSort: {
//            field: 'autonum' //排序字段，对应 cols 设定的各字段名
//            ,type: 'asc' //排序方式  asc: 升序、desc: 降序、null: 默认排序
//        }
//		,height: 'full-600'
        ,cols: [[ //标题栏
            {checkbox: true}, //默认全选
			{field: 'autonum', title: 'No.',filter: 'autonum', width: 80, sort: true}
            ,{field: 'batch', title: '批次时间', width: 230, sort: true}
            ,{field: 'note', title: '备注', width: 230}
            ,{field: 'ctrl', title: '导出操作', width: 460, toolbar: "#exportTools"}
        ]]
        ,skin: 'row' //表格风格
        ,even: true
        ,page: true //是否显示分页
        ,limits: [5,10,15,20]
        ,limit: 10 //每页默认显示的数量
        ,done: function(res, curr, count){
            //如果是异步请求数据方式，res即为你接口返回的信息。
            //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
            $(".total").children("strong").html(count);
        }
    });
    //excel上传
    var uploadInst = upload.render({
        elem: '#upload_excel' //绑定元素
        ,url: "{:url('admin/Order/importData')}" //上传接口
		,accept: "file"
		,exts: "xls|xlsx"
		,field: "excelFile"
		,auto: false
		,multiple: false
		,bindAction: "#upcommit"
		,choose: function (obj) {
            obj.preview(function(index, file, result){
                $("#filetips").html(file.name);
                $("#filetips").show();
            });
            var that = this;
            layer.prompt({
                formType: "2",
                value: '',
                title: '请输入当前数据批次的备注',
                area: ['500px', '250px'] //自定义文本域宽高
            }, function(value, index, elem){
                that.data.note = value;
                layer.close(index);
                $("#upcommit").click();
            });
            $("#upcommit").show();
        }
        , done: function (res) {
            //上传完毕回调
            layer.closeAll('loading');
            $("#filetips").hide();
            $("#upcommit").hide();
			if (res.code == 0000) {
			    layer.open({
					content: "导入数据成功！",
					end: function () {
                        table.reload('main', {
                            url: '{:url(\'order/getDatas\')}'
                            ,where: {} //设定异步数据接口的额外参数
                        });
                    }
				});
			}else{
                layer.open({
                    content: "导入数据失败，可能是工作表不合法，请更换表后重试，仍然失败请找管理猿！"
                });
                console.log(res.error);
			}
        }
        , error: function () {
            //请求异常回调
            layer.closeAll('loading');
            $("#filetips").hide();
            $("#upcommit").hide();
            layer.open({
                content: "上传失败！"
            });
        }
    });

//同步服务端排序
//    table.on('sort(olist)', function(obj){ //注：tool是工具条事件名，autonum是table原始容器的属性 lay-filter="对应的值"
////        console.log(obj.field); //当前排序的字段名
////        console.log(obj.type); //当前排序类型：desc（降序）、asc（升序）、null（空对象，默认排序）
////        console.log($(this)); //当前排序的 th 对象
//
//        //尽管我们的 table 自带排序功能，但并没有请求服务端。
//        //有些时候，你可能需要根据当前排序的字段，重新向服务端发送请求，如：
//        table.reload('main', {
//            initSort: obj //记录初始排序，如果不设的话，将无法标记表头的排序状态。 layui 2.1.1 新增参数
//            ,where: { //请求参数
//                field: obj.field //排序字段
//                ,order: obj.type //排序方式
//            }
//        });
//    });

	//监听导出操作工具条
	table.on("tool(olist)",function (obj) {
	    var data = obj.data;
		if (obj.event == "jiushou_ex") {
		    $("input[name='ex_info']").val(data.batch+"|"+1);
            $("#postData").submit();
		}else if(obj.event == "list_ex") {
            $("input[name='ex_info']").val(data.batch+"|"+2);
            $("#postData").submit();
		}else if(obj.event == "entry_ex") {
            $("input[name='ex_info']").val(data.batch+"|"+3);
            $("#postData").submit();
        }else if(obj.event == "transprot_ex") {
            $("input[name='ex_info']").val(data.batch+"|"+4);
            $("#postData").submit();
        }else if(obj.event == "all_ex") {
            $("input[name='ex_info']").val(data.batch+"|"+5);
            $("#postData").submit();
        }
    })
});

$(document).ready(function () {
    $("#upcommit").hide();
});

function searchFun(type) {

}

//上传请求时的动画
function uploading() {
    layer.load(0,{shade:0.3}); //换了种风格
}

//导出表格时，请求数据的组装
function exportTable(num) {
    layui.use(['table','layer'],function (table,layer) {
        var $ = layui.jquery;
		var checkStatus = table.checkStatus('main');
		data = checkStatus.data;
		if (data.length>0) {
			//将被选中的数据对象转换成字符串，后通过表单向后台提交并获取导出的文件
            html = '';
            html+= "<input type=\"text\" name=\"datatype\" value='"+num+"'>";
            $(data).each(function (index,obj) {
                html+= "<input type=\"text\" name=\"data[]\" value='"+obj.batch+"'>";
			});
            $("#batch_ex").append(html);
            $("#batch_ex").submit().empty();
        }else{
		    layer.msg("没选择数据呀",{'time':"1000"});
		}
    });
}

//显示高级查询
function searchAdv() {
    $(".search").toggle("500");
    $("#search-form").toggle("1000");
}

</script> 
</body>
</html>